import {baseURL} from '@/utils/config.js'
import store from '@/store/store.js'
export default function request(body) {
	return new Promise((resolve, reject) => {
		uni.request({
			header: {
				'Authorization': uni.getStorageSync('oauth_token')
			},
			url: baseURL+body.url,
			method: body.method ? body.method : "POST",
			data: body.data ? body.data : {},
			success: (res) => {
				if(res.data.code === 401){
					store.commit("setIsLogin_mutation", false);
					uni.clearStorageSync('oauth_token')
				}
				resolve(res.data)
			},
			fail(err) {
				console.log(err)
			}
		})
	})
}
